﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Specialized;
using com.hisun.iposm.net;
using pay.BLL;
using pay.DAL;
using pay.Entity;
using System.Collections.Generic;
public partial class callback : System.Web.UI.Page
{
    public static log4net.ILog log = log4net.LogManager.GetLogger(typeof(callback));
    protected void Page_Load(object sender, EventArgs e)
    {
        //支付结果通知
        NameValueCollection param = Request.Params;
        MerchantPayResult res = null;
       

        try
        {
            res = HiSunTransEngine.payResult(param);
            if (res.status == "SUCCESS")
            {
                //OrderBLL orderbll = new OrderBLL();
                //if (orderbll.UpdateOrderSucess(res.orderId) == true)
                //{
                   
                //    OrderDetailBLL ordetail_bll = new OrderDetailBLL();
                //    Web_Order orders = orderbll.GetOrderByOrderNumber(res.orderId);
                //    if (orders.SourceType == 3)
                //    {
                //        //id:49 为6各月版， 50为12个月
                //        WebService.emoneybusiness eb = new WebService.emoneybusiness();
                //        List<OrderDetails> ordersdetail = new List<OrderDetails>();
                //        ordersdetail = ordetail_bll.GetOrderByOrderNumber(res.orderId);

                //        int usetime = 0;
                //        string tel = "";
                //        string productname = "";
                //        string pwd = "";
                //        string msg = "";
                //        foreach (var c in ordersdetail)
                //        {
                //            switch (c.Productid)
                //            {
                //                case 36:    //益盟操盘手专业版6个月版
                //                    usetime = 6;
                //                    productname = "益盟操盘手专业版6个月测试版";
                //                    break;
                //                case 48:    // 益盟操盘手盯盘先锋1个月版
                //                    usetime = 1;
                //                    productname = "益盟操盘手盯盘先锋1个月版";
                //                    break;
                //                case 50:   //益盟操盘手专业版12个月版
                //                    usetime = 12;
                //                    productname = "益盟操盘手专业版12个月版";
                //                    break;
                //                default:
                //                    break;

                //            }
                //        }
                //        OrderDetailBLL dbl = new OrderDetailBLL();
                //        if (!string.IsNullOrEmpty(res.reserved))
                //        {
                //            tel = res.reserved;
                //        }
                //        else
                //        {
                //            return;
                //        }
                //        string reValue = dbl.GetActiveUserPwd(tel, usetime);
                //        if (string.IsNullOrEmpty(reValue))
                //        {
                //            return;
                //        }//if 用户还没有激活
                //        try
                //        {
                //            var array = reValue.Split(',');
                //            pwd = array[0];
                //            msg = array[1];
                //            Session["pwd"] = pwd;
                //            Session["msg"] = msg;
                //            string msgs = "您订购的" + productname + "" +msg + "软件登录用户名为您的手机号，";
                //            msgs += "密码为:" + pwd+ ",如有疑问请拨打我们的免费服务热线：400-670-6668";
                //            eb.SendMsg(tel, msgs);//发送短信
                //        }
                //        catch
                //        { }
                Response.Redirect("http://localhost:33213/pay/guChina/shopping33.aspx?orderId=" + res.orderId + "&msg=success");

                //    }// if 炒股大赛产品
                    //else
                    //{
                    //    Response.Redirect("http://qq.emoney.cn/shopping3.aspx?orderID=" + res.orderId);

                    //}//else 非炒股大赛产品

                //}//if 支付成功

            }
            else
            {
                //orderId.Text = res.orderId;
                //amount.Text = "" + res.amount;
                //banks.Text = res.banks;
                //mobile.Text = res.mobile;
                //message.Text = res.status;

                Response.Redirect("http://localhost:33213/pay/kuaiqian/show.aspx?msg=false");

            }


        }
        catch
        { }
            
       }
      
       
        //errMsg.Text = res.errMsg;
        //returnCode.Text = res.returnCode;
        //message.Text = res.message;
        //status.Text = res.status;

        //amount.Text = "" + res.amount;
        //amtItem.Text = "" + res.amtItem;
        //banks.Text = res.banks;
        //contractName.Text = res.contractName;
        //invoiceTitle.Text = res.invoiceTitle;
        //mobile.Text = res.mobile;
        //orderId.Text = res.orderId;
        //payDate.Text = res.payDate;
        //payNo.Text = res.payNo;
        //authorizeNo.Text = res.authorizeNo;
        //reserved.Text = res.reserved;
        

    
}
